from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app =Flask(__name__)

# 设置数据库配置信息
app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://root:123456@127.0.0.1:3306/test"
# 增加开销，设置false。不会追踪数据库
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

# 创建对象
db =SQLAlchemy(app)

class Student(db.Model):
    id = db.Column(db.Integer,primary_key=True)
    name = db.Column(db.String(32))


@app.route("/")
def hello():
    return "hello"

if __name__ == '__main__':
    # 创建数据库表，创建集成db.Model
    # 删除继承自db.Model表
    # db.drop_all()
    db.create_all()
    app.run(debug=True)